import { ExternalLink } from 'lucide-react'; import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound, permanentRedirect } from 'next/navigation'; import { HistoryChart } from '@/components/benchmarks/leaderboard'; import { FrontierChart, GroupPicker, Leaderboard2 } from '@/components/benchmarks/leaderboard2'; import { CompareTrayBar } from '@/components/compare/compare-tray-bar'; import { ComparabilityLegend } from '@/components/entity/model-blocks'; import { TerminalLayout } from '@/components/layout/terminal'; import { ViewBeacon } from '@/components/layout/view-beacon'; import { TrustBadge } from '@/components/models/badges'; import { fmtScoreUnit, TRUST_LONG } from '@/components/models/shared'; import { EntityBadge, StatusBadge } from '@/components/ui/badges'; import { EntityLink, QualityMark } from '@/components/ui/entity'; import { KeyValue, type KVRow } from '@/components/ui/key-value'; import { Container, Note } from '@/components/ui/section'; import { Unavailable } from '@/components/ui/unavailable'; import { api, ApiError, apiD1, safe } from '@/lib/api'; import { cn } from '@/lib/cn'; import { fmtAgo, fmtDate, fmtInt, num } from '@/lib/format'; import { routes, SITE_NAME, SITE_URL } from '@/lib/site'; import type { BenchmarkDetail, Group } from '@/lib/types'; /* Benchmark leaderboard page 2.0 — TerminalLayout: filters (comparability group · trust · organization · comparable-only) · main (variant navigation, frontier over time, one-row-per-model leaderboard) · inspector (definition with evidence, trust mix, links). */ type SP = Record; type Params = { params: Promise<{ slug: string }>; searchParams: Promise }; const LIMIT = 100; export const revalidate = 300; async function loadBenchmark(slug: string): Promise { try { const d = await apiD1.benchmark(slug); if (d.entity_type !== 'benchmark') notFound(); return d; } catch (e) { if (e instanceof ApiError && e.notFound) notFound(); throw e; } } export async function generateMetadata({ params }: Params): Promise { const { slug } = await params; const d = await safe(apiD1.benchmark(slug)); if (!d || d.entity_type !== 'benchmark' || d.slug !== slug) return { title: 'Benchmark', robots: { index: false } }; const title = `${d.name} Leaderboard & Results`; const leader = d.leaderboard?.[0]; const description = `${d.name}${d.category ? ` (${d.category})` : ''}: ${fmtInt(d.result_count ?? 0)} current results across ${fmtInt(d.model_count ?? 0)} canonical models, metric ${d.metric ?? '—'}${leader ? `; current recorded leader ${leader.model.name} at ${fmtScoreUnit(leader.score, leader.unit)} (${leader.trust_label})` : ''}. Comparability groups, trust levels, frontier over time and per-model history on ${SITE_NAME}.`.slice(0, 300); const canonical = routes.benchmark(d.slug); return { title, description, alternates: { canonical }, openGraph: { title: `${title} | ${SITE_NAME}`, description, url: `${SITE_URL}${canonical}`, type: 'article', siteName: SITE_NAME }, twitter: { card: 'summary_large_image', title, description } }; } export default async function BenchmarkPage({ params, searchParams }: Params) { const { slug } = await params; const sp = await searchParams; const d = await loadBenchmark(slug); if (d.slug !== slug) permanentRedirect(routes.benchmark(d.slug)); const canonical = routes.benchmark(d.slug); // Group from `?group=metric|config_key` (select form) or `?metric=&config_key=` (links). let metric = sp.metric?.trim() || undefined; let configKey = sp.config_key?.trim() || undefined; if (sp.group?.includes('|')) [metric, configKey] = sp.group.split('|') as [string, string]; const trust = sp.trust?.trim() || undefined; const org = sp.org?.trim() || undefined; const comparableOnly = sp.comparable_only === '1'; const offset = Math.max(0, Number(sp.offset) || 0); const model = sp.model?.trim() || undefined; const [lb, frontier, list, history] = await Promise.all([ safe(apiD1.leaderboard(d.slug, { metric, config_key: configKey, trust, org, comparable_only: comparableOnly ? 1 : undefined, limit: LIMIT, offset })), safe(apiD1.frontier(d.slug, { metric, config_key: configKey })), safe(apiD1.benchmarks()), model ? safe(api.benchmarkHistory(d.slug, model)) : Promise.resolve(null), ]); const group: Group | null = lb?.group ?? d.primary_group ?? null; const groups = lb?.groups ?? d.groups ?? []; const a = d.attributes ?? {}; const unit = typeof a.unit === 'string' ? a.unit : (lb?.items[0]?.unit ?? null); const item = list?.items.find((b) => b.slug === d.slug) ?? null; const siblings = list?.items.filter((b) => (b.family ?? b.slug) === (d.family ?? item?.family ?? d.slug)).sort((x, y) => Number(!!y.attributes?.family_head) - Number(!!x.attributes?.family_head) || (num(y.result_count) ?? 0) - (num(x.result_count) ?? 0)) ?? []; const cur: SP = { metric, config_key: configKey, trust, org, comparable_only: comparableOnly ? '1' : undefined, model }; const href = (patch: SP) => { const p = new URLSearchParams(); for (const [k, v] of Object.entries({ ...cur, ...patch })) if (v) p.set(k, v); const s = p.toString(); return `${canonical}${s ? `?${s}` : ''}`; }; const link = (k: string) => (typeof a[k] === 'string' && /^https?:\/\//.test(a[k] as string) ? (a[k] as string) : null); const site = link('website') ?? link('official_url'); const defRows: KVRow[] = [ { key: 'task', raw: a.task }, { key: 'metric', raw: a.metric_label ?? a.metric, value: typeof (a.metric_label ?? a.metric) === 'string' ? {String(a.metric_label ?? a.metric)}{unit && · {unit}}{a.higher_is_better === false ? · lower is better : ''} : undefined }, { key: 'metric_min', label: 'Metric range', raw: num(a.metric_min) !== null && num(a.metric_max) !== null ? `${a.metric_min} – ${a.metric_max}` : undefined }, { key: 'variant', raw: a.variant }, { key: 'version', raw: a.version }, { key: 'harness', raw: a.harness }, { key: 'comparability_note', label: 'Comparability note', raw: a.comparability_note }, { key: 'known_limitations', raw: a.known_limitations }, { key: 'paper', raw: a.paper }, { key: 'paper_url', raw: a.paper_url }, { key: 'website', raw: a.website }, { key: 'creator', raw: a.creator }, ]; const trustMix = lb?.group?.trust_mix ?? d.trust_mix ?? item?.trust_mix ?? {}; const filterCount = [trust, org, comparableOnly ? '1' : undefined, configKey].filter(Boolean).length; const ld = { '@context': 'https://schema.org', '@type': 'Dataset', name: `${d.name} leaderboard`, url: `${SITE_URL}${canonical}`, description: d.description ?? (typeof a.task === 'string' ? a.task : undefined), alternateName: d.aliases?.length ? d.aliases : undefined, measurementTechnique: typeof a.metric === 'string' ? a.metric : undefined, sameAs: [site, link('paper')].filter(Boolean), variableMeasured: typeof a.metric === 'string' ? a.metric : undefined }; const empty = (num(d.result_count) ?? 0) === 0; const filters = (

Comparability group

href({ metric: g.metric, config_key: g.config_key, offset: undefined })} slug={d.slug} hidden={{ trust, org, comparable_only: cur.comparable_only }} />
{Object.keys(trustMix).length > 0 && (

Trust level

  • All {fmtInt(Object.values(trustMix).reduce((n, v) => n + v, 0))}
  • {Object.entries(trustMix) .sort((x, y) => y[1] - x[1]) .map(([k, n]) => (
  • {fmtInt(n)}
  • ))}
)}
{metric && } {configKey && } {trust && }
Reset

Views

  • Cost vs performance →
  • In the matrix →
  • Timeline →
); const inspector = (
{group && (

Active group

{group.label}

{fmtInt(group.model_count)} models · {fmtInt(group.n)} current rows

)}

Comparability

{d.aliases?.length > 0 && (

Also known as

{d.aliases.join(', ')}

)}

slug {d.slug} · {d.id}

{lb?.methodology && {lb.methodology}}
); return ( <>